<?php

/**
 * IndexController - Index
 *
 * @author Fernando Dias Oliveira <rodox17@gmail.com>
 * @package intranet
 * @subpackage controller
 */

class IndexController extends AppBaseController 
{
	public function init()
	{
		parent::init();		
	}

    public function indexAction() 
    {
	
    }
    
	public function getcookielistAction()
	{
		error_reporting(0);
		echo json_encode($_COOKIE["novoped"]);
		
		exit;
	}
    
	public function setcookielistAction()
	{
		$stat = $this->_request->getPost("stat");
		
		setcookie("novoped", $stat);
		
		exit;
	}
	
	public function adicionarItemPedidoAction(){
		$caf04=new caf04;
		$item=$_POST["item"];
		$pedido=$_POST["pedido"];
		$caf04->insert(array("caf04_cod_item"=>$pedido,"caf04_cod_prod"=>$item,"caf04_qtd"=>1));
		exit;
	}
    
    public function homeAction()
    {
    	$caf=new caf04();
    	
    	$db=$caf->getAdapter();

    	$this->view->rs=$db->fetchAll("SELECT caf05_cod, caf05_prod, COUNT( caf05_cod ) AS total, caf05_car
						FROM  `caf04` 
						LEFT JOIN caf05 ON ( caf04_cod_prod = caf05_cod ) 
						GROUP BY caf05_cod ORDER BY total desc
						LIMIT 5");
    	  $this->_helper->layout->disableLayout();
    }
}

?>